package com.gameShare.constances

import com.gameShare.config.AppConfig
import jakarta.annotation.PostConstruct
import org.springframework.stereotype.Component
import java.io.File

@Component
class FilePaths(private val appConfig: AppConfig) {


    val coverPath = "cover"

    lateinit var captchaPath : String

    lateinit var imagePaths : Array<String>

    @PostConstruct
    fun afterInjectFinish() {
        captchaPath = linkPath( arrayOf("captcha"))

        imagePaths = arrayOf(coverPath)
    }

    fun linkPath(paths: Array<String>) : String {
        return linkPath(appConfig.basePath, paths)
    }

    fun linkPath(src: String, paths: Array<String>): String {
        // 将 src 添加到路径数组的开头
        val allPaths = arrayOf(src) + paths
        // 使用 joinToString 拼接所有路径
        return allPaths.joinToString(File.separator) + File.separator
    }
}